home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWTValMultiSet.z / RWTValMultiSet
Encoding:
Text File  |  2002-10-03  |  20.9 KB  |  529 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))                                      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTValMultiSet<T,C> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/tvmset.h>
  13.  
  14.  
  15.  
  16.               RWTValMultiSet<T,C>
  17.  
  18. SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy DDDDeeeeppppeeeennnnddddeeeennnntttt!!!!
  19.      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt requires the Standard C++ Library.
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      This class maintains a collection of values, which are ordered according
  24.      to a comparison object of type CCCC.  CCCC must induce a total ordering on
  25.      elements of type T via a public member
  26.           bbbboooooooollll ooooppppeeeerrrraaaattttoooorrrr(((())))((((ccccoooonnnnsssstttt TTTT&&&& xxxx,,,, ccccoooonnnnsssstttt TTTT&&&& yyyy)))) ccccoooonnnnsssstttt which returns ttttrrrruuuueeee if
  27.      xxxx should precede yyyy within the collection.  The structure lllleeeessssssss<<<<TTTT>>>> from the
  28.      C++-standard header file <<<<ffffuuuunnnnccccttttiiiioooonnnnaaaallll>>>> is an example.  RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>
  29.      may contain multiple items that compare equal to each other.
  30.      (RRRRWWWWTTTTVVVVaaaallllSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> will not accept an item that compares equal to an item
  31.      already in the collection.)
  32.  
  33. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  34.      Isomorphic.
  35.  
  36. EEEExxxxaaaammmmpppplllleeeessss
  37.      In this example, a multi-set of RRRRWWWWCCCCSSSSttttrrrriiiinnnnggggs is exercised.
  38.  
  39.               //
  40.  
  41.  
  42.  
  43.               // tvmsstr.cpp
  44.           //
  45.           #include <rw/tvmset.h>
  46.           #include <rw/cstring.h>
  47.           #include <iostream.h>
  48.           main(){
  49.            RWTValMultiSet<RWCString,less<RWCString> > set;
  50.             set.insert("one");
  51.             set.insert("two");
  52.             set.insert("three");
  53.             set.insert("one");               // OK, duplicates allowed
  54.             cout << set.entries() << endl;   // Prints "4"
  55.             return 0;
  56.           }
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))                                      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74. RRRReeeellllaaaatttteeeedddd CCCCllllaaaasssssssseeeessss
  75.      Class RRRRWWWWTTTTVVVVaaaallllSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> offers the same interface to a collection that will
  76.      not accept multiple items that compare equal to each other.
  77.      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,CCCC>>>> maintains a collection of key-value pairs.  Class
  78.      mmmmuuuullllttttiiiisssseeeetttt<<<<TTTT,,,,CCCC,,,,aaaallllllllooooccccaaaattttoooorrrr>>>> is the C++-standard collection that serves as the
  79.      underlying implementation for RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>.
  80.  
  81. PPPPuuuubbbblllliiiicccc TTTTyyyyppppeeeeddddeeeeffffssss
  82.               typedef multiset<T,C,allocator>                container_type;
  83.           typedef container_type::iterator               iterator;
  84.           typedef container_type::const_iterator         const_iterator;
  85.           typedef container_type::size_type              size_type;
  86.           typedef T                                      value_type;
  87.           typedef const T&                               const_reference;
  88.  
  89.  
  90.  
  91. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  92.               RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const C& cmp = C());
  93.  
  94.  
  95.      Constructs an empty set.
  96.  
  97.               RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const container_type& s);
  98.  
  99.  
  100.      Constructs a set by copying all elements of ssss.
  101.  
  102.               RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const RWTValMultiSet<T,C>& rws);
  103.  
  104.  
  105.      Copy constructor.
  106.  
  107.               RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>
  108.           (const T* first,const T* last,const C& cmp = C());
  109.  
  110.  
  111.      Constructs a set by copying elements from the array of TTTTs pointed to by
  112.      ffffiiiirrrrsssstttt, up to, but not including, the element pointed to by llllaaaasssstttt.
  113.  
  114. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  115.               RWTValMultiSet<T,C>&
  116.           ooooppppeeeerrrraaaattttoooorrrr====(const RWTValMultiSet<T,C>& s);
  117.           RWTValMultiSet<T,C>&
  118.           ooooppppeeeerrrraaaattttoooorrrr====(const container_type& s);
  119.  
  120.  
  121.      Destroys all elements of self and replaces them by copying all elements
  122.      of ssss.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))                                      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               bool
  141.           ooooppppeeeerrrraaaattttoooorrrr<<<<(const RWTValMultiSet<T,C>& s) const;
  142.  
  143.  
  144.  
  145.               bool
  146.           ooooppppeeeerrrraaaattttoooorrrr<<<<(const container_type& s) const;
  147.  
  148.  
  149.      Returns ttttrrrruuuueeee if self compares lexicographically less than ssss, otherwise
  150.      returns ffffaaaallllsssseeee.  Assumes that type TTTT has well-defined less-than semantics
  151.      (TTTT::::::::ooooppppeeeerrrraaaattttoooorrrr<<<<((((ccccoooonnnnsssstttt TTTT&&&&)))) or equivalent).
  152.  
  153.               bool
  154.           ooooppppeeeerrrraaaattttoooorrrr========(const RWTValMultiSet<T,C>& s) const;
  155.           bool
  156.           ooooppppeeeerrrraaaattttoooorrrr========(const container_type& s) const;
  157.  
  158.  
  159.      Returns ttttrrrruuuueeee if self compares equal to ssss, otherwise returns ffffaaaallllsssseeee.  Two
  160.      collections are equal if both have the same number of entries, and
  161.      iterating through both collections produces, in turn, individual elements
  162.      that compare equal to each other.
  163.  
  164. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  165.               void
  166.           aaaappppppppllllyyyy(void (*fn)(const_reference,void*), void* d) const;
  167.  
  168.  
  169.      Applies the user-defined function pointed to by ffffnnnn to every item in the
  170.      collection.  This function must have prototype:
  171.  
  172.  
  173.  
  174.  
  175.  
  176.                  void yourfun(const_reference a, void* d);
  177.  
  178.  
  179.      Client data may be passed through parameter dddd.
  180.  
  181.               iterator
  182.           bbbbeeeeggggiiiinnnn();
  183.           const_iterator
  184.           bbbbeeeeggggiiiinnnn() const;
  185.  
  186.  
  187.      Returns an iterator positioned at the first element of self.
  188.  
  189.               void
  190.           cccclllleeeeaaaarrrr();
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))                                      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Clears the collection by removing all items from self.  Each item will
  207.      have its destructor called.
  208.  
  209.               bool
  210.           ccccoooonnnnttttaaaaiiiinnnnssss(const_reference a) const;
  211.  
  212.  
  213.      Returns ttttrrrruuuueeee if there exists an element tttt in self that compares equal to
  214.      aaaa, otherwise returns ffffaaaallllsssseeee.
  215.  
  216.               bool
  217.           ccccoooonnnnttttaaaaiiiinnnnssss(bool (*fn)(const_reference, void*), void* d) const;
  218.  
  219.  
  220.      Returns ttttrrrruuuueeee if there exists an element tttt in self such that the
  221.      expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee, otherwise returns ffffaaaallllsssseeee.  ffffnnnn points to a
  222.      user-defined tester function which must have prototype:
  223.  
  224.                  bool yourTester(const_reference a, void* d);
  225.  
  226.  
  227.  
  228.  
  229.  
  230.      Client data may be passed through parameter dddd.
  231.  
  232.               void
  233.           ddddiiiiffffffffeeeerrrreeeennnncccceeee(const RWTValMultiSet<T,C>& s);
  234.           void
  235.           ddddiiiiffffffffeeeerrrreeeennnncccceeee(const container_type& s);
  236.  
  237.  
  238.      Sets self to the set-theoretic difference given by ((((sssseeeellllffff ---- ssss)))).
  239.  
  240.               iterator
  241.           eeeennnndddd();
  242.           const_iterator
  243.           eeeennnndddd() const;
  244.  
  245.  
  246.      Returns an iterator positioned "just past" the last element in self.
  247.  
  248.               size_type
  249.           eeeennnnttttrrrriiiieeeessss() const;
  250.  
  251.  
  252.      Returns the number of items in self.
  253.  
  254.               bool
  255.           ffffiiiinnnndddd(const_reference a, T& k) const;
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))                                      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      If there exists an element tttt in self that compares equal to aaaa, assigns tttt
  273.      to kkkk and returns ttttrrrruuuueeee.  Otherwise, returns ffffaaaallllsssseeee and leaves the value of
  274.      kkkk unchanged.
  275.  
  276.               bool
  277.           ffffiiiinnnndddd(bool (*fn)(const_reference,void*), void* d, T& k) const;
  278.  
  279.  
  280.      If there exists an element tttt in self such that the expression
  281.      ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee, assigns tttt to kkkk and returns ttttrrrruuuueeee.  Otherwise,
  282.      returns ffffaaaallllsssseeee and leaves the value of kkkk unchanged.  ffffnnnn points to a user-
  283.      defined tester function which must have prototype:
  284.  
  285.  
  286.  
  287.  
  288.  
  289.                  bool yourTester(const_reference a, void* d);
  290.  
  291.  
  292.      Client data may be passed through parameter dddd.
  293.  
  294.               void
  295.           iiiinnnntttteeeerrrrsssseeeeccccttttiiiioooonnnn(const RWTValMultiSet<T,C>& s);
  296.           void
  297.           iiiinnnntttteeeerrrrsssseeeeccccttttiiiioooonnnn(const container_type& s);
  298.  
  299.  
  300.      Sets self to the intersection of self and ssss.
  301.  
  302.               bool
  303.           iiiinnnnsssseeeerrrrtttt(const_reference a);
  304.  
  305.  
  306.      Adds the item aaaa to the collection.  Returns ttttrrrruuuueeee.
  307.  
  308.               bool
  309.           iiiissssEEEEmmmmppppttttyyyy() const;
  310.  
  311.  
  312.      Returns ttttrrrruuuueeee if there are no items in the collection, ffffaaaallllsssseeee otherwise.
  313.  
  314.               bool
  315.           iiiissssEEEEqqqquuuuiiiivvvvaaaalllleeeennnntttt(const RWTValMultiSet<T,C>& s) const;
  316.  
  317.  
  318.      Returns ttttrrrruuuueeee if there is set equivalence between self and ssss, and returns
  319.      ffffaaaallllsssseeee otherwise.
  320.  
  321.               bool
  322.           iiiissssPPPPrrrrooooppppeeeerrrrSSSSuuuubbbbsssseeeettttOOOOffff(const RWTValMultiSet<T,C>& s) const;
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))                                      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.      Returns ttttrrrruuuueeee if self is a proper subset of ssss, and returns  ffffaaaallllsssseeee
  339.      otherwise.
  340.  
  341.               bool
  342.           iiiissssSSSSuuuubbbbsssseeeettttOOOOffff(const RWTValMultiSet<T,C>& s) const;
  343.  
  344.  
  345.      Returns ttttrrrruuuueeee if self is a subset of ssss or if self is set equivalent to
  346.      rrrrhhhhssss, ffffaaaallllsssseeee otherwise.
  347.  
  348.               size_type
  349.           ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const_reference a) const;
  350.  
  351.  
  352.      Returns the number of elements tttt in self that compare equal to aaaa.
  353.  
  354.               size_type
  355.           ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(bool (*fn)(const_reference,void*),void* d) const;
  356.  
  357.  
  358.      Returns the number of elements tttt in self such that the
  359.      expression((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee.  ffffnnnn points to a user-defined tester
  360.      function which must have prototype:
  361.  
  362.  
  363.  
  364.  
  365.  
  366.                  bool yourTester(const_reference a, void* d);
  367.  
  368.  
  369.      Client data may be passed through parameter dddd.
  370.  
  371.               bool
  372.           rrrreeeemmmmoooovvvveeee(const_reference a);
  373.  
  374.  
  375.      Removes the first element tttt in self that compares equal to aaaa and returns
  376.      ttttrrrruuuueeee.  Returns ffffaaaallllsssseeee if there is no such element.
  377.  
  378.               bool
  379.           rrrreeeemmmmoooovvvveeee(bool (*fn)(const_reference,void*), void* d);
  380.  
  381.  
  382.      Removes the first element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd))))))))
  383.      is ttttrrrruuuueeee and returns ttttrrrruuuueeee.  Returns ffffaaaallllsssseeee if there is no such element.  ffffnnnn
  384.      points to a user-defined tester function which must have prototype:
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))                                      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))
  401.  
  402.  
  403.  
  404.                  bool yourTester(const_reference a, void* d);
  405.  
  406.  
  407.      Client data may be passed through parameter dddd.
  408.  
  409.               size_type
  410.           rrrreeeemmmmoooovvvveeeeAAAAllllllll(const_reference a);
  411.  
  412.  
  413.      Removes all elements tttt in self that compare equal to aaaa.  Returns the
  414.      number of items removed.
  415.  
  416.               size_type
  417.           rrrreeeemmmmoooovvvveeeeAAAAllllllll(bool (*fn)(const_reference,void*), void* d);
  418.  
  419.  
  420.      Removes all elements tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd))))))))is
  421.      ttttrrrruuuueeee.  Returns the number of items removed.  ffffnnnn points to a user-defined
  422.      tester function which must have prototype:
  423.  
  424.  
  425.  
  426.  
  427.  
  428.                  bool yourTester(const_reference a, void* d);
  429.  
  430.  
  431.      Client data may be passed through parameter dddd.
  432.  
  433.               multiset<T,C,allocator>&
  434.           ssssttttdddd();
  435.           const multiset<T,C,allocator>&
  436.           ssssttttdddd() const;
  437.  
  438.  
  439.      Returns a reference to the underlying C++-standard collection that serves
  440.      as the implementation for self.  This reference may be used freely,
  441.      providing access to the C++-standard interface as well as
  442.      interoperability with other software components that make use of the
  443.      C++-standard collections.
  444.  
  445.               void
  446.           ssssyyyymmmmmmmmeeeettttrrrriiiiccccDDDDiiiiffffffffeeeerrrreeeennnncccceeee(const RWTValMultiSet<T,C>& s);
  447.           void
  448.           ssssyyyymmmmmmmmeeeettttrrrriiiiccccDDDDiiiiffffffffeeeerrrreeeennnncccceeee(const container_type& s);
  449.  
  450.  
  451.      Sets self to the symmetric difference of self and ssss.
  452.  
  453.               void
  454.           UUUUnnnniiiioooonnnn(const RWTValMultiSet<T,C>& s);
  455.           void
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))                                      RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++))))
  467.  
  468.  
  469.  
  470.           UUUUnnnniiiioooonnnn(const container_type& s);
  471.  
  472.  
  473.      Sets self to the union of self and ssss.  Note the use of the uppercase
  474.      "U"in UUUUnnnniiiioooonnnn to avoid conflict with the C++ reserved word.
  475.  
  476. RRRReeeellllaaaatttteeeedddd GGGGlllloooobbbbaaaallll OOOOppppeeeerrrraaaattttoooorrrrssss
  477.               RWvostream&
  478.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWvostream& strm, const RWTValMultiSet<T,C>& coll);
  479.           RWFile&
  480.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWFile& strm, const RWTValMultiSet<T,C>& coll);
  481.  
  482.  
  483.      Saves the collection ccccoooollllllll onto the output stream ssssttttrrrrmmmm, or a reference to
  484.      it if it has already been saved.
  485.  
  486.               RWvistream&
  487.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTValMultiSet<T,C>& coll);
  488.           RWFile&
  489.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTValMultiSet<T,C>& coll);
  490.  
  491.  
  492.      Restores the contents of the collection ccccoooollllllll from the input stream ssssttttrrrrmmmm.
  493.  
  494.               RWvistream&
  495.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTValMultiSet<T,C>*& p);
  496.           RWFile&
  497.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTValMultiSet<T,C>*& p);
  498.  
  499.  
  500.      Looks at the next object on the input stream ssssttttrrrrmmmm and either creates a
  501.      new collection off the heap and sets pppp to point to it, or sets pppp to point
  502.      to a previously read instance.  If a collection is created off the heap,
  503.      then you are responsible for deleting it.
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.